#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int main(){
	int n,l,r,b=0,k=0;
	freopen("candy.in","r",stdin);
	cin>>n>>l>>r;
	freopen("candy.out","w",stdout);
	for(int i=l;i<=r;i++){
		if(i%n>b){
			b=i%n;
		}	
	}
	cout<<b;
}
